/*==============================================================*/
/* DBMS name:      Microsoft SQL Server 2005                    */
/* Created on:     2012-7-2 21:05:48                            */
/*==============================================================*/


if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('admin_role') and o.name = 'FK9FC63FA6C7B24C48')
alter table admin_role
   drop constraint FK9FC63FA6C7B24C48
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('area') and o.name = 'FK1F44ADB4D9BB21')
alter table area
   drop constraint FK1F44ADB4D9BB21
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('article') and o.name = 'FK379164D65A9A516')
alter table article
   drop constraint FK379164D65A9A516
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('articlecategory') and o.name = 'FKC9FF4FF4AC430CA0')
alter table articlecategory
   drop constraint FKC9FF4FF4AC430CA0
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('cartitem') and o.name = 'FK4393E73CA10C3E')
alter table cartitem
   drop constraint FK4393E73CA10C3E
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('deliveryitem') and o.name = 'FK326C4547425C301E')
alter table deliveryitem
   drop constraint FK326C4547425C301E
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('deliverytype') and o.name = 'FK3271596E37A10E7D')
alter table deliverytype
   drop constraint FK3271596E37A10E7D
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('deposit') and o.name = 'FKBFDFAE7ECA10C3E')
alter table deposit
   drop constraint FKBFDFAE7ECA10C3E
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('member') and o.name = 'FK892776BA60FA1EDE')
alter table member
   drop constraint FK892776BA60FA1EDE
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('member_memberattributemapstore') and o.name = 'FK854979A267DDC435')
alter table member_memberattributemapstore
   drop constraint FK854979A267DDC435
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('member_product') and o.name = 'FK9460284A15D7A056')
alter table member_product
   drop constraint FK9460284A15D7A056
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('message') and o.name = 'FK9C2397E7145FF3D4')
alter table message
   drop constraint FK9C2397E7145FF3D4
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('orderitem') and o.name = 'FK60163F613F4585B6')
alter table orderitem
   drop constraint FK60163F613F4585B6
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('orderlog') and o.name = 'FK4D6C1D363F4585B6')
alter table orderlog
   drop constraint FK4D6C1D363F4585B6
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('orders') and o.name = 'FKC3DF62E590BFCB96')
alter table orders
   drop constraint FKC3DF62E590BFCB96
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('payment') and o.name = 'FK3454C9E613C6C4B6')
alter table payment
   drop constraint FK3454C9E613C6C4B6
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('product') and o.name = 'FK50C664CF59CF1676')
alter table product
   drop constraint FK50C664CF59CF1676
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('product_productattributemapstore') and o.name = 'FK7B6203E2B1184188')
alter table product_productattributemapstore
   drop constraint FK7B6203E2B1184188
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('productattribute') and o.name = 'FKDDC65E8D738B3AF6')
alter table productattribute
   drop constraint FKDDC65E8D738B3AF6
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('productcategory') and o.name = 'FKD05546EDB2990399')
alter table productcategory
   drop constraint FKD05546EDB2990399
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('receiver') and o.name = 'FKD3A64E0FCA10C3E')
alter table receiver
   drop constraint FKD3A64E0FCA10C3E
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('refund') and o.name = 'FK91ACCB9813C6C4B6')
alter table refund
   drop constraint FK91ACCB9813C6C4B6
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('reship') and o.name = 'FK91B2830F3F4585B6')
alter table reship
   drop constraint FK91B2830F3F4585B6
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('role_resource') and o.name = 'FKE25F2DB75BD93F78')
alter table role_resource
   drop constraint FKE25F2DB75BD93F78
go

if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('shipping') and o.name = 'FKE51541CE3F4585B6')
alter table shipping
   drop constraint FKE51541CE3F4585B6
go

if exists (select 1
            from  sysobjects
           where  id = object_id('admin')
            and   type = 'U')
   drop table admin
go

if exists (select 1
            from  sysobjects
           where  id = object_id('admin_role')
            and   type = 'U')
   drop table admin_role
go

if exists (select 1
            from  sysobjects
           where  id = object_id('agreement')
            and   type = 'U')
   drop table agreement
go

if exists (select 1
            from  sysobjects
           where  id = object_id('area')
            and   type = 'U')
   drop table area
go

if exists (select 1
            from  sysobjects
           where  id = object_id('article')
            and   type = 'U')
   drop table article
go

if exists (select 1
            from  sysobjects
           where  id = object_id('articlecategory')
            and   type = 'U')
   drop table articlecategory
go

if exists (select 1
            from  sysobjects
           where  id = object_id('brand')
            and   type = 'U')
   drop table brand
go

if exists (select 1
            from  sysobjects
           where  id = object_id('cartitem')
            and   type = 'U')
   drop table cartitem
go

if exists (select 1
            from  sysobjects
           where  id = object_id('deliverycorp')
            and   type = 'U')
   drop table deliverycorp
go

if exists (select 1
            from  sysobjects
           where  id = object_id('deliveryitem')
            and   type = 'U')
   drop table deliveryitem
go

if exists (select 1
            from  sysobjects
           where  id = object_id('deliverytype')
            and   type = 'U')
   drop table deliverytype
go

if exists (select 1
            from  sysobjects
           where  id = object_id('deposit')
            and   type = 'U')
   drop table deposit
go

if exists (select 1
            from  sysobjects
           where  id = object_id('footer')
            and   type = 'U')
   drop table footer
go

if exists (select 1
            from  sysobjects
           where  id = object_id('friendlink')
            and   type = 'U')
   drop table friendlink
go

if exists (select 1
            from  sysobjects
           where  id = object_id('log')
            and   type = 'U')
   drop table log
go

if exists (select 1
            from  sysobjects
           where  id = object_id('logconfig')
            and   type = 'U')
   drop table logconfig
go

if exists (select 1
            from  sysobjects
           where  id = object_id('member')
            and   type = 'U')
   drop table member
go

if exists (select 1
            from  sysobjects
           where  id = object_id('member_memberattributemapstore')
            and   type = 'U')
   drop table member_memberattributemapstore
go

if exists (select 1
            from  sysobjects
           where  id = object_id('member_product')
            and   type = 'U')
   drop table member_product
go

if exists (select 1
            from  sysobjects
           where  id = object_id('memberattribute')
            and   type = 'U')
   drop table memberattribute
go

if exists (select 1
            from  sysobjects
           where  id = object_id('memberrank')
            and   type = 'U')
   drop table memberrank
go

if exists (select 1
            from  sysobjects
           where  id = object_id('message')
            and   type = 'U')
   drop table message
go

if exists (select 1
            from  sysobjects
           where  id = object_id('navigation')
            and   type = 'U')
   drop table navigation
go

if exists (select 1
            from  sysobjects
           where  id = object_id('orderitem')
            and   type = 'U')
   drop table orderitem
go

if exists (select 1
            from  sysobjects
           where  id = object_id('orderlog')
            and   type = 'U')
   drop table orderlog
go

if exists (select 1
            from  sysobjects
           where  id = object_id('orders')
            and   type = 'U')
   drop table orders
go

if exists (select 1
            from  sysobjects
           where  id = object_id('payment')
            and   type = 'U')
   drop table payment
go

if exists (select 1
            from  sysobjects
           where  id = object_id('paymentconfig')
            and   type = 'U')
   drop table paymentconfig
go

if exists (select 1
            from  sysobjects
           where  id = object_id('product')
            and   type = 'U')
   drop table product
go

if exists (select 1
            from  sysobjects
           where  id = object_id('product_productattributemapstore')
            and   type = 'U')
   drop table product_productattributemapstore
go

if exists (select 1
            from  sysobjects
           where  id = object_id('productattribute')
            and   type = 'U')
   drop table productattribute
go

if exists (select 1
            from  sysobjects
           where  id = object_id('productcategory')
            and   type = 'U')
   drop table productcategory
go

if exists (select 1
            from  sysobjects
           where  id = object_id('producttype')
            and   type = 'U')
   drop table producttype
go

if exists (select 1
            from  sysobjects
           where  id = object_id('receiver')
            and   type = 'U')
   drop table receiver
go

if exists (select 1
            from  sysobjects
           where  id = object_id('refund')
            and   type = 'U')
   drop table refund
go

if exists (select 1
            from  sysobjects
           where  id = object_id('reship')
            and   type = 'U')
   drop table reship
go

if exists (select 1
            from  sysobjects
           where  id = object_id('resource')
            and   type = 'U')
   drop table resource
go

if exists (select 1
            from  sysobjects
           where  id = object_id('role')
            and   type = 'U')
   drop table role
go

if exists (select 1
            from  sysobjects
           where  id = object_id('role_resource')
            and   type = 'U')
   drop table role_resource
go

if exists (select 1
            from  sysobjects
           where  id = object_id('shipping')
            and   type = 'U')
   drop table shipping
go

/*==============================================================*/
/* Table: admin                                                 */
/*==============================================================*/
create table admin (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   department           varchar(255)         null default NULL,
   email                varchar(255)         not null,
   isAccountEnabled     tinyint              not null,
   isAccountExpired     tinyint              not null,
   isAccountLocked      tinyint              not null,
   isCredentialsExpired tinyint              not null,
   lockedDate           datetime             null default NULL,
   loginDate            datetime             null default NULL,
   loginFailureCount    int                  not null,
   loginIp              varchar(255)         null default NULL,
   name                 varchar(255)         null default NULL,
   password             varchar(255)         not null,
   username             varchar(255)         not null,
   constraint PK_ADMIN primary key nonclustered (id),
   constraint UK_ADMIN_USERNAME unique (username)
)
go

/*==============================================================*/
/* Table: admin_role                                            */
/*==============================================================*/
create table admin_role (
   adminSet_id          varchar(32)          not null,
   roleSet_id           varchar(32)          not null,
   constraint PK_ADMIN_ROLE primary key nonclustered (adminSet_id, roleSet_id)
)
go

/*==============================================================*/
/* Table: agreement                                             */
/*==============================================================*/
create table agreement (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   content              text                 null,
   constraint PK_AGREEMENT primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: area                                                  */
/*==============================================================*/
create table area (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   name                 varchar(255)         not null,
   path                 text                 null,
   parent_id            varchar(32)          null default NULL,
   constraint PK_AREA primary key nonclustered (id),
   constraint UK_AREA_NAME unique (name, parent_id)
)
go

/*==============================================================*/
/* Table: article                                               */
/*==============================================================*/
create table article (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   author               varchar(255)         null default NULL,
   content              text                 not null,
   hits                 int                  not null,
   htmlFilePath         varchar(255)         null default NULL,
   isPublication        tinyint              not null,
   isRecommend          tinyint              not null,
   isTop                tinyint              not null,
   metaDescription      text                 null,
   metaKeywords         text                 null,
   pageCount            int                  not null,
   title                varchar(255)         not null,
   articleCategory_id   varchar(32)          not null,
   constraint PK_ARTICLE primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: articlecategory                                       */
/*==============================================================*/
create table articlecategory (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   metaDescription      text                 null,
   metaKeywords         text                 null,
   name                 varchar(255)         not null,
   orderList            int                  not null,
   path                 text                 null,
   parent_id            varchar(32)          null default NULL,
   constraint PK_ARTICLECATEGORY primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: brand                                                 */
/*==============================================================*/
create table brand (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   introduction         text                 null,
   logo                 varchar(255)         null default NULL,
   name                 varchar(255)         not null,
   orderList            int                  not null,
   url                  varchar(255)         null default NULL,
   constraint PK_BRAND primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: cartitem                                              */
/*==============================================================*/
create table cartitem (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   quantity             int                  not null,
   product_id           varchar(32)          not null,
   member_id            varchar(32)          not null,
   constraint PK_CARTITEM primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: deliverycorp                                          */
/*==============================================================*/
create table deliverycorp (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   name                 varchar(255)         not null,
   orderList            int                  not null,
   url                  varchar(255)         null default NULL,
   constraint PK_DELIVERYCORP primary key nonclustered (id),
   constraint UK_DELIVERYCORP_NAME unique (name)
)
go

/*==============================================================*/
/* Table: deliveryitem                                          */
/*==============================================================*/
create table deliveryitem (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   deliveryQuantity     int                  not null,
   productHtmlFilePath  varchar(255)         not null,
   productName          varchar(255)         not null,
   productSn            varchar(255)         not null,
   shipping_id          varchar(32)          null default NULL,
   product_id           varchar(32)          null default NULL,
   reship_id            varchar(32)          null default NULL,
   constraint PK_DELIVERYITEM primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: deliverytype                                          */
/*==============================================================*/
create table deliverytype (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   continueWeight       double precision     not null,
   continueWeightPrice  decimal(15,5)        not null,
   continueWeightUnit   int                  not null,
   deliveryMethod       int                  not null,
   description          text                 null,
   firstWeight          double precision     not null,
   firstWeightPrice     decimal(15,5)        not null,
   firstWeightUnit      int                  not null,
   name                 varchar(255)         not null,
   orderList            int                  not null,
   defaultDeliveryCorp_id varchar(32)          null default NULL,
   constraint PK_DELIVERYTYPE primary key nonclustered (id),
   constraint UK_DELIVERYTYPE_NAME unique (name)
)
go

/*==============================================================*/
/* Table: deposit                                               */
/*==============================================================*/
create table deposit (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   balance              decimal(19,2)        not null,
   credit               decimal(19,2)        not null,
   debit                decimal(19,2)        not null,
   depositType          int                  not null,
   member_id            varchar(32)          null default NULL,
   constraint PK_DEPOSIT primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: footer                                                */
/*==============================================================*/
create table footer (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   content              text                 null,
   constraint PK_FOOTER primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: friendlink                                            */
/*==============================================================*/
create table friendlink (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   logo                 varchar(255)         null default NULL,
   name                 varchar(255)         not null,
   orderList            int                  not null,
   url                  varchar(255)         not null,
   constraint PK_FRIENDLINK primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: log                                                   */
/*==============================================================*/
create table log (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   actionClassName      varchar(255)         not null,
   actionMethodName     varchar(255)         not null,
   info                 text                 null,
   ip                   varchar(255)         not null,
   operationName        varchar(255)         not null,
   operator             varchar(255)         not null,
   constraint PK_LOG primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: logconfig                                             */
/*==============================================================*/
create table logconfig (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   actionClassName      varchar(255)         not null,
   actionMethodName     varchar(255)         not null,
   description          text                 null,
   operationName        varchar(255)         not null,
   constraint PK_LOGCONFIG primary key nonclustered (id),
   constraint UK_LOGCONFIG_OPERATIONNAME unique (operationName),
   constraint UK_LOGCONFIG_ACTIONCLASSNAME unique (actionClassName, actionMethodName)
)
go

/*==============================================================*/
/* Table: member                                                */
/*==============================================================*/
create table member (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   deposit              decimal(15,5)        not null,
   email                varchar(255)         not null,
   isAccountEnabled     tinyint              not null,
   isAccountLocked      tinyint              not null,
   lockedDate           datetime             null default NULL,
   loginDate            datetime             null default NULL,
   loginFailureCount    int                  not null,
   loginIp              varchar(255)         null default NULL,
   password             varchar(255)         not null,
   passwordRecoverKey   varchar(255)         null default NULL,
   point                int                  not null,
   registerIp           varchar(255)         not null,
   safeAnswer           varchar(255)         null default NULL,
   safeQuestion         varchar(255)         null default NULL,
   username             varchar(255)         not null,
   memberRank_id        varchar(32)          not null,
   constraint PK_MEMBER primary key nonclustered (id),
   constraint UK_MEMBER_USERNAME unique (username)
)
go

/*==============================================================*/
/* Table: member_memberattributemapstore                        */
/*==============================================================*/
create table member_memberattributemapstore (
   Member_id            varchar(32)          not null,
   element              varchar(255)         null default NULL,
   mapkey_id            varchar(32)          not null,
   constraint PK_MEMBER_MEMBERATTRIBUTEMAPST primary key nonclustered (Member_id, mapkey_id)
)
go

/*==============================================================*/
/* Table: member_product                                        */
/*==============================================================*/
create table member_product (
   favoriteMemberSet_id varchar(32)          not null,
   favoriteProductSet_id varchar(32)          not null,
   constraint PK_MEMBER_PRODUCT primary key nonclustered (favoriteMemberSet_id, favoriteProductSet_id)
)
go

/*==============================================================*/
/* Table: memberattribute                                       */
/*==============================================================*/
create table memberattribute (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   attributeOptionStore varchar(255)         null default NULL,
   attributeType        int                  not null,
   isEnabled            tinyint              not null,
   isRequired           tinyint              not null,
   name                 varchar(255)         not null,
   orderList            int                  not null,
   constraint PK_MEMBERATTRIBUTE primary key nonclustered (id),
   constraint UK_MEMBERTTRIBUTE_NAME unique (name)
)
go

/*==============================================================*/
/* Table: memberrank                                            */
/*==============================================================*/
create table memberrank (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   isDefault            tinyint              not null,
   name                 varchar(255)         not null,
   point                int                  not null,
   preferentialScale    double precision     not null,
   constraint PK_MEMBERRANK primary key nonclustered (id),
   constraint UK_MEMBERRANK_NAME unique (name),
   constraint UK_MEMBERRANK_POINT unique (point)
)
go

/*==============================================================*/
/* Table: message                                               */
/*==============================================================*/
create table message (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   content              text                 not null,
   deleteStatus         int                  not null,
   isRead               tinyint              not null,
   isSaveDraftbox       tinyint              not null,
   title                varchar(255)         not null,
   fromMember_id        varchar(32)          null default NULL,
   toMember_id          varchar(32)          null default NULL,
   constraint PK_MESSAGE primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: navigation                                            */
/*==============================================================*/
create table navigation (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   isBlankTarget        tinyint              not null,
   isVisible            tinyint              not null,
   name                 varchar(255)         not null,
   orderList            int                  not null,
   position             int                  not null,
   url                  varchar(255)         not null,
   constraint PK_NAVIGATION primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: orderitem                                             */
/*==============================================================*/
create table orderitem (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   deliveryQuantity     int                  not null,
   productHtmlFilePath  varchar(255)         not null,
   productName          varchar(255)         not null,
   productPrice         decimal(15,5)        not null,
   productQuantity      int                  not null,
   productSn            varchar(255)         not null,
   totalDeliveryQuantity int                  not null,
   product_id           varchar(32)          null default NULL,
   order_id             varchar(32)          null,
   constraint PK_ORDERITEM primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: orderlog                                              */
/*==============================================================*/
create table orderlog (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   info                 text                 null,
   operator             varchar(255)         null default NULL,
   orderLogType         int                  not null,
   orderSn              varchar(255)         not null,
   order_id             varchar(32)          null,
   constraint PK_ORDERLOG primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: orders                                                */
/*==============================================================*/
create table orders (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   deliveryFee          decimal(15,5)        not null,
   deliveryTypeName     varchar(255)         not null,
   memo                 text                 null,
   orderSn              varchar(255)         not null,
   orderStatus          int                  not null,
   paidAmount           decimal(15,5)        not null,
   paymentConfigName    varchar(255)         not null,
   paymentFee           decimal(15,5)        not null,
   paymentStatus        int                  not null,
   productTotalPrice    decimal(15,5)        not null,
   productTotalQuantity int                  not null,
   productWeight        decimal(19,5)        not null,
   productWeightUnit    int                  not null,
   shipAddress          varchar(255)         not null,
   shipArea             varchar(255)         not null,
   shipAreaPath         varchar(255)         null default NULL,
   shipMobile           varchar(255)         null default NULL,
   shipName             varchar(255)         not null,
   shipPhone            varchar(255)         null default NULL,
   shipZipCode          varchar(255)         not null,
   shippingStatus       int                  not null,
   totalAmount          decimal(15,5)        not null,
   member_id            varchar(32)          null default NULL,
   deliveryType_id      varchar(32)          null default NULL,
   paymentConfig_id     varchar(32)          null default NULL,
   constraint PK_ORDERS primary key nonclustered (id),
   constraint UK_ORDERS_ORDERSN unique (orderSn)
)
go

/*==============================================================*/
/* Table: payment                                               */
/*==============================================================*/
create table payment (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   bankAccount          varchar(255)         null default NULL,
   bankName             varchar(255)         null default NULL,
   memo                 text                 null,
   operator             varchar(255)         null default NULL,
   payer                varchar(255)         not null,
   paymentConfigName    varchar(255)         not null,
   paymentFee           decimal(15,5)        not null,
   paymentSn            varchar(255)         not null,
   paymentStatus        int                  not null,
   paymentType          int                  not null,
   totalAmount          decimal(15,5)        not null,
   deposit_id           varchar(32)          null default NULL,
   order_id             varchar(32)          null default NULL,
   paymentConfig_id     varchar(32)          null default NULL,
   constraint PK_PAYMENT primary key nonclustered (id),
   constraint UK_PAYMENT_PAYMENTSN unique (paymentSn)
)
go

/*==============================================================*/
/* Table: paymentconfig                                         */
/*==============================================================*/
create table paymentconfig (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   configObjectStore    varchar(255)         null default NULL,
   description          text                 null,
   name                 varchar(255)         not null,
   orderList            int                  not null,
   paymentConfigType    int                  not null,
   paymentFee           decimal(15,5)        null default NULL,
   paymentFeeType       int                  not null,
   constraint PK_PAYMENTCONFIG primary key nonclustered (id),
   constraint UK_PAYMENTCONFIG_NAME unique (name)
)
go

/*==============================================================*/
/* Table: product                                               */
/*==============================================================*/
create table product (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   description          text                 null,
   freezeStore          int                  not null,
   htmlFilePath         varchar(255)         not null,
   isBest               tinyint              not null,
   isHot                tinyint              not null,
   isMarketable         tinyint              not null,
   isNew                tinyint              not null,
   marketPrice          decimal(15,5)        not null,
   metaDescription      text                 null,
   metaKeywords         text                 null,
   name                 varchar(255)         not null,
   point                int                  not null,
   price                decimal(15,5)        not null,
   productImageListStore text                 null,
   productSn            varchar(255)         not null,
   store                int                  null default NULL,
   weight               double precision     not null,
   weightUnit           int                  not null,
   brand_id             varchar(32)          null default NULL,
   productCategory_id   varchar(32)          not null,
   productType_id       varchar(32)          null default NULL,
   constraint PK_PRODUCT primary key nonclustered (id),
   constraint UK_PRODUCT_PRODUCTSN unique (productSn)
)
go

/*==============================================================*/
/* Table: product_productattributemapstore                      */
/*==============================================================*/
create table product_productattributemapstore (
   Product_id           varchar(32)          not null,
   element              varchar(255)         null default NULL,
   mapkey_id            varchar(32)          not null,
   constraint PK_PRODUCT_PRODUCTATTRIBUTEMAP primary key nonclustered (Product_id, mapkey_id)
)
go

/*==============================================================*/
/* Table: productattribute                                      */
/*==============================================================*/
create table productattribute (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   attributeOptionStore varchar(255)         null default NULL,
   attributeType        int                  not null,
   isEnabled            tinyint              not null,
   isRequired           tinyint              not null,
   name                 varchar(255)         not null,
   orderList            int                  not null,
   productType_id       varchar(32)          not null,
   constraint PK_PRODUCTATTRIBUTE primary key nonclustered (id),
   constraint UK_PRODUCTATTRIBUTE_NAME unique (name, productType_id)
)
go

/*==============================================================*/
/* Table: productcategory                                       */
/*==============================================================*/
create table productcategory (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   metaDescription      text                 null,
   metaKeywords         text                 null,
   name                 varchar(255)         not null,
   orderList            int                  not null,
   path                 text                 null,
   parent_id            varchar(32)          null default NULL,
   constraint PK_PRODUCTCATEGORY primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: producttype                                           */
/*==============================================================*/
create table producttype (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   name                 varchar(255)         not null,
   constraint PK_PRODUCTTYPE primary key nonclustered (id),
   constraint UK_PRODUCTTYPE_NAME unique (name)
)
go

/*==============================================================*/
/* Table: receiver                                              */
/*==============================================================*/
create table receiver (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   address              text                 not null,
   areaPath             text                 not null,
   isDefault            tinyint              not null,
   mobile               varchar(255)         null default NULL,
   name                 varchar(255)         not null,
   phone                varchar(255)         null default NULL,
   zipCode              varchar(255)         not null,
   member_id            varchar(32)          not null,
   constraint PK_RECEIVER primary key nonclustered (id)
)
go

/*==============================================================*/
/* Table: refund                                                */
/*==============================================================*/
create table refund (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   bankAccount          varchar(255)         null default NULL,
   bankName             varchar(255)         null default NULL,
   memo                 text                 null,
   operator             varchar(255)         null default NULL,
   payee                varchar(255)         not null,
   paymentConfigName    varchar(255)         not null,
   refundSn             varchar(255)         not null,
   refundType           int                  not null,
   totalAmount          decimal(15,5)        not null,
   deposit_id           varchar(32)          null default NULL,
   order_id             varchar(32)          null default NULL,
   paymentConfig_id     varchar(32)          null default NULL,
   constraint PK_REFUND primary key nonclustered (id),
   constraint UK_REFUND_REFUNDSN unique (refundSn)
)
go

/*==============================================================*/
/* Table: reship                                                */
/*==============================================================*/
create table reship (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   deliveryCorpName     varchar(255)         not null,
   deliveryFee          decimal(19,2)        not null,
   deliverySn           varchar(255)         null default NULL,
   deliveryTypeName     varchar(255)         not null,
   memo                 varchar(255)         null default NULL,
   reshipSn             varchar(255)         not null,
   shipAddress          varchar(255)         not null,
   shipArea             varchar(255)         not null,
   shipAreaPath         varchar(255)         null default NULL,
   shipMobile           varchar(255)         null default NULL,
   shipName             varchar(255)         not null,
   shipPhone            varchar(255)         null default NULL,
   shipZipCode          varchar(255)         not null,
   deliveryType_id      varchar(32)          null default NULL,
   order_id             varchar(32)          null,
   constraint PK_RESHIP primary key nonclustered (id),
   constraint UK_RESHIP_RESHIPSN unique (reshipSn)
)
go

/*==============================================================*/
/* Table: resource                                              */
/*==============================================================*/
create table resource (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   description          text                 null,
   isSystem             tinyint              not null,
   name                 varchar(255)         not null,
   orderList            int                  not null,
   value                varchar(255)         not null,
   constraint PK_RESOURCE primary key nonclustered (id),
   constraint UK_RESOURCE_NAME unique (name),
   constraint UK_RESOURCE_VALUE unique (value)
)
go

/*==============================================================*/
/* Table: role                                                  */
/*==============================================================*/
create table role (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   description          text                 null,
   isSystem             tinyint              not null,
   name                 varchar(255)         not null,
   value                varchar(255)         not null,
   constraint PK_ROLE primary key nonclustered (id),
   constraint UK_ROLE_NAME unique (name),
   constraint UK_ROLE_VALUE unique (value)
)
go

/*==============================================================*/
/* Table: role_resource                                         */
/*==============================================================*/
create table role_resource (
   roleSet_id           varchar(32)          not null,
   resourceSet_id       varchar(32)          not null,
   constraint PK_ROLE_RESOURCE primary key nonclustered (roleSet_id, resourceSet_id)
)
go

/*==============================================================*/
/* Table: shipping                                              */
/*==============================================================*/
create table shipping (
   id                   varchar(32)          not null,
   createDate           datetime             null default NULL,
   modifyDate           datetime             null default NULL,
   deliveryCorpName     varchar(255)         not null,
   deliveryFee          decimal(19,2)        not null,
   deliverySn           varchar(255)         null default NULL,
   deliveryTypeName     varchar(255)         not null,
   memo                 varchar(255)         null default NULL,
   shipAddress          varchar(255)         not null,
   shipArea             varchar(255)         not null,
   shipAreaPath         varchar(255)         null default NULL,
   shipMobile           varchar(255)         null default NULL,
   shipName             varchar(255)         not null,
   shipPhone            varchar(255)         null default NULL,
   shipZipCode          varchar(255)         not null,
   shippingSn           varchar(255)         not null,
   deliveryType_id      varchar(32)          null default NULL,
   order_id             varchar(32)          null,
   constraint PK_SHIPPING primary key nonclustered (id),
   constraint UK_SHIPPING_SHIPPINGSN unique (shippingSn)
)
go

alter table admin_role
   add constraint FK9FC63FA6C7B24C48 foreign key (roleSet_id)
      references role (id)
go

alter table area
   add constraint FK1F44ADB4D9BB21 foreign key (parent_id)
      references area (id)
go

alter table article
   add constraint FK379164D65A9A516 foreign key (articleCategory_id)
      references articlecategory (id)
go

alter table articlecategory
   add constraint FKC9FF4FF4AC430CA0 foreign key (parent_id)
      references articlecategory (id)
go

alter table cartitem
   add constraint FK4393E73CA10C3E foreign key (member_id)
      references member (id)
go

alter table deliveryitem
   add constraint FK326C4547425C301E foreign key (reship_id)
      references reship (id)
go

alter table deliverytype
   add constraint FK3271596E37A10E7D foreign key (defaultDeliveryCorp_id)
      references deliverycorp (id)
go

alter table deposit
   add constraint FKBFDFAE7ECA10C3E foreign key (member_id)
      references member (id)
go

alter table member
   add constraint FK892776BA60FA1EDE foreign key (memberRank_id)
      references memberrank (id)
go

alter table member_memberattributemapstore
   add constraint FK854979A267DDC435 foreign key (mapkey_id)
      references memberattribute (id)
go

alter table member_product
   add constraint FK9460284A15D7A056 foreign key (favoriteProductSet_id)
      references product (id)
go

alter table message
   add constraint FK9C2397E7145FF3D4 foreign key (fromMember_id)
      references member (id)
go

alter table orderitem
   add constraint FK60163F613F4585B6 foreign key (order_id)
      references orders (id)
go

alter table orderlog
   add constraint FK4D6C1D363F4585B6 foreign key (order_id)
      references orders (id)
go

alter table orders
   add constraint FKC3DF62E590BFCB96 foreign key (paymentConfig_id)
      references paymentconfig (id)
go

alter table payment
   add constraint FK3454C9E613C6C4B6 foreign key (deposit_id)
      references deposit (id)
go

alter table product
   add constraint FK50C664CF59CF1676 foreign key (productCategory_id)
      references productcategory (id)
go

alter table product_productattributemapstore
   add constraint FK7B6203E2B1184188 foreign key (mapkey_id)
      references productattribute (id)
go

alter table productattribute
   add constraint FKDDC65E8D738B3AF6 foreign key (productType_id)
      references producttype (id)
go

alter table productcategory
   add constraint FKD05546EDB2990399 foreign key (parent_id)
      references productcategory (id)
go

alter table receiver
   add constraint FKD3A64E0FCA10C3E foreign key (member_id)
      references member (id)
go

alter table refund
   add constraint FK91ACCB9813C6C4B6 foreign key (deposit_id)
      references deposit (id)
go

alter table reship
   add constraint FK91B2830F3F4585B6 foreign key (order_id)
      references orders (id)
go

alter table role_resource
   add constraint FKE25F2DB75BD93F78 foreign key (resourceSet_id)
      references resource (id)
go

alter table shipping
   add constraint FKE51541CE3F4585B6 foreign key (order_id)
      references orders (id)
go

